package com.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.dao.QuatationDao;
import com.entity.Quatation;

@Repository
public class QuatationDaoImpl implements QuatationDao {

	@Resource
	protected SessionFactory sessionFactory;

	@Override
	public long count() {

		return (Long) sessionFactory.getCurrentSession()
				.createQuery("select count(*) from " + Quatation.class.getSimpleName()).uniqueResult();
	}

	@Override
	public List<Quatation> list(int pos, int row) {
		return sessionFactory.getCurrentSession().createQuery("from " + Quatation.class.getSimpleName())
				.setMaxResults(row).setFirstResult(pos).list();
	}
}
